package per.turtle.common.mq.service.impl;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;
import per.turtle.common.mq.enums.ExchangeTypeEnum;
import per.turtle.common.mq.po.Msg;
import per.turtle.common.mq.service.MqProducerService;

/**
 * @author yuj
 */
@Service
public class MqProducerServiceImpl implements MqProducerService {

    @Autowired
    RabbitTemplate rabbitTemplate;

    @Override
    public void publishMsg(ExchangeTypeEnum exchangeEnum, @Nullable String routingKey, Msg msg) {
        rabbitTemplate.convertAndSend(exchangeEnum.getCode(), routingKey, msg);
    }

}
